export default {
  tid: null,
  refresh() {
    const app = document.getElementById('app-service');
    const appMaxHeight = app.offsetWidth * (9 / 16);
    const navbarNeedHeight = (2 / 28.125) * appMaxHeight;
    const centerNeedHeight = (20.5 / 28.125) * appMaxHeight;
    const freeNeedHeight = (0.5 / 28.125) * appMaxHeight;
    const appMinHeight = navbarNeedHeight + centerNeedHeight + (2 * freeNeedHeight);
    const winHeight = window.innerHeight;
    if (winHeight < appMinHeight) {
      app.style.height = `${appMinHeight}px`;
    } else if (winHeight > appMaxHeight) {
      app.style.height = `${appMaxHeight}px`;
    } else {
      app.style.height = `${winHeight}px`;
    }
  },
  run() {
    clearTimeout(this.tid);
    this.tid = setTimeout(this.refresh, 150);
  },
};

